#ifndef	TERRAINMANAGER_H
#define TERRAINMANAGER_H

#include "d3dUtil.h"
#include "Terrain.h"
#include "TerrainInformation.h"
#include "TerrainEffects.h"

class TerrainManager
{
public:
	TerrainManager(void);
	~TerrainManager(void);

	void Init(ID3D10Device* devcie);

	void AddTerrain(const TerrainInformation& info ,const D3DXVECTOR3& position);

	//rendering all the terrain
	void Rendering();

	void SetDirectionToSun(const D3DXVECTOR3& dir);

	void Destory();

private:
	class TerrainBlock
	{
	public:
		void Init(ID3D10Device* devcie,const TerrainInformation& info);
		Terrain* GetTerrain();
		D3DXMATRIX& GetWorldMatrix();
		void SetWorldMatrix(const D3DXMATRIX& world);
		void SetBuffer();
		void Destory();
	private:
		Terrain		m_terrain;
		D3DXMATRIX	m_matWorld;
	};

private:
	ID3D10Device*					m_pDevice;
	Effect::TerrainEffects			m_TerrainEffect;
	std::vector<TerrainBlock>		m_TerrainList;
};


#endif